Don't include images/categories when behind a local interwiki prefix
[lhc/web/wiklou.git] / includes / title / MediaWikiTitleCodec.php
index 8798de5..6ca0799 100644 (file)
@@ -25,7 +25,7 @@
 /**
  * A codec for %MediaWiki page titles.
  *
- * @note: Normalization and validation is applied while parsing, not when formatting.
+ * @note Normalization and validation is applied while parsing, not when formatting.
  * It's possible to construct a TitleValue with an invalid title, and use MediaWikiTitleCodec
  * to generate an (invalid) title string from it. TitleValues should be constructed only
  * via parseTitle() or from a (semi)trusted source, such as the database.
@@ -49,8 +49,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
        protected $localInterwikis;
 
        /**
-        * @param Language $language the language object to use for localizing namespace names.
-        * @param GenderCache $genderCache the gender cache for generating gendered namespace names
+        * @param Language $language The language object to use for localizing namespace names.
+        * @param GenderCache $genderCache The gender cache for generating gendered namespace names
         * @param string[]|string $localInterwikis
         */
        public function __construct( Language $language, GenderCache $genderCache,
@@ -67,7 +67,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
         * @param int $namespace
         * @param string $text
         *
-        * @throws InvalidArgumentException if the namespace is invalid
+        * @throws InvalidArgumentException If the namespace is invalid
         * @return string
         */
        public function getNamespaceName( $namespace, $text ) {
@@ -97,7 +97,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
         *        Underscores will be replaced.
         * @param string $fragment The fragment name (may be empty).
         *
-        * @throws InvalidArgumentException if the namespace is invalid
+        * @throws InvalidArgumentException If the namespace is invalid
         * @return string
         */
        public function formatTitle( $namespace, $text, $fragment = '' ) {
@@ -187,10 +187,10 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
         * namespace prefixes, sets the other forms, and canonicalizes
         * everything.
         *
-        * @todo: this method is only exposed as a temporary measure to ease refactoring.
+        * @todo this method is only exposed as a temporary measure to ease refactoring.
         * It was copied with minimal changes from Title::secureAndSplit().
         *
-        * @todo: This method should be split up and an appropriate interface
+        * @todo This method should be split up and an appropriate interface
         * defined for use by the Title class.
         *
         * @param string $text
@@ -206,6 +206,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                # Initialisation
                $parts = array(
                        'interwiki' => '',
+                       'local_interwiki' => false,
                        'fragment' => '',
                        'namespace' => $defaultNamespace,
                        'dbkey' => $dbkey,
@@ -282,6 +283,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                                                                $mainPage = Title::newMainPage();
                                                                return array(
                                                                        'interwiki' => $mainPage->getInterwiki(),
+                                                                       'local_interwiki' => true,
                                                                        'fragment' => $mainPage->getFragment(),
                                                                        'namespace' => $mainPage->getNamespace(),
                                                                        'dbkey' => $mainPage->getDBkey(),
@@ -289,6 +291,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                                                                );
                                                        }
                                                        $parts['interwiki'] = '';
+                                                       # local interwikis should behave like initial-colon links
+                                                       $parts['local_interwiki'] = true;
 
                                                        # Do another namespace split...
                                                        continue 2;